package pocket;

import java.util.ArrayList;

public class Notebook {
    // ArrayList 叫容器类型，类似python的list
    private ArrayList<String> notes = new ArrayList<String>();
    private int index;
    private int size = 0;

    public void add(String s) {
        notes.add(s);
    }

    public int getSize() {
        return notes.size();
    }

    public String getNote(int index) {
        return notes.get(index);
    }

    public void removeNote(int index) {
        notes.remove(index);
    }

    public ArrayList<String> list1() {
        return notes;
    }

    public String[] list2() {
        String[] a = new String[getSize()];
        return notes.toArray(a);
    }

    public static void main(String[] args) {
        // for testing
        Notebook nb = new Notebook();
        nb.add("first");
        nb.add("second");
        nb.add("third");
        System.out.println(nb.getSize());
        nb.removeNote(0);
        for (String s: nb.list2()) {
            System.out.println(s);
        }

        Notebook[] notebooks = new Notebook[10];
        notebooks[0] = nb;
        notebooks[1] = nb;
        for (Notebook n: notebooks) {
            if (n != null) {
                System.out.println(n.getSize());
            }
        }
    }
}
